import {
  createRouter,
  createWebHistory,
  createWebHashHistory,
  useRoute
} from 'vue-router'
// 使用第一个菜单路径作为默认路由
let firstRoutePath = ''
if (location.pathname != '/login') {
  firstRoutePath = localStorage.getItem('firstRoutePath') as string
}
const routes = [
  {
    path: '/',
    name: 'Layout',
    component: () => import('@/components/Layout.vue'),
    children: [],
    redirect: firstRoutePath,
    meta: {
      hide: true
    }
  },
  {
    path: '/login',
    component: () => import('@/views/login/index.vue'),
    meta: {
      hide: true
    }
  },

  {
    path: '/404',
    name: 'NotFound',
    component: () => import('@/views/404.vue'),
    meta: {
      hide: true
    }
  },
  {
    path: '/:pathMatch(.*)*',
    redirect: '/404',
    meta: {
      hide: true
    }
  }
] as any

const router = createRouter({
  history: createWebHistory(),
  routes
})

export default router
